package acm.蓝桥排序枚举杯;

import java.util.Arrays;
import java.util.Scanner;

public class C {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int[] arr=new int[sc.nextInt()];
        int k=sc.nextInt();
        for (int i = 0; i < arr.length; i++) {
            arr[i]=sc.nextInt();
        }
//        int[] arr={1,2,3,4,5};
//        int k=2;
        long res = fun2(arr, k);
        System.out.println(res);
    }

    public static int getAns(int[] arr,int k) {
        int[] s = new int[100005], xb = new int[100005];
        for (int i = 1; i <= arr.length; i++) {
            s[i] = s[i - 1] + arr[i-1];
        }
        int ans = 0;
        for (int i = 0; i <= arr.length; i++) {
            ans += xb[(int) (s[i] % k)]++;
        }
        return ans;
    }

    public static long fun2(int[] arr, int k) {
        long res=0;
        int[] copy=new int[arr.length]; //记录每个下标对应的次数
        for (int i = 0; i < arr.length; i++) {
            int mod = arr[i] % k;
            if (mod==0){
                copy[i]=(i-1>=0?copy[i-1]:0)+1;
            }else{
                for (int j=i-1;j>=0;j--){
                    mod=(mod+arr[j])%k;
                    if (mod==0){
                        copy[i]=(j>=1?copy[j-1]:0)+1;
                        break;
                    }
                }
            }
            res+=copy[i];
        }
        return res;
    }
}

class Test1{
    public static void main(String[] args) {
        compare();
    }
    public static void compare(){
        int count=10000;
        while (count-- > 0) {
            int k= (int) (Math.random()*100000+2);
            int[] arr=new int[(int) (Math.random()*100+1)];
            for (int i = 0; i < arr.length; i++) {
                arr[i]= (int) (Math.random()*100000+1);
            }
            long a = C.fun2(arr, k);
            long b = C.getAns(arr, k);
            if (a!=b){
                System.out.println(k);
                System.out.println(Arrays.toString(arr));
                System.out.println("预期："+b);
                System.out.println("实际："+a);
            }
        }
    }
}
